package master.ghrm.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Version;

@Entity
public class QuestionOption extends AbstractBaseEntity {
	private static final long serialVersionUID = 1L;

	public static final int LENGTH_TEXT = 255;

	@Version
	private Long version;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "question_option_id")
	private Integer questionOptionId;

	private Boolean preselected;

	@Column(name = "text", length = LENGTH_TEXT)
	private String text;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "question_id", nullable = false)
	private ChoiceQuestion question;

	/**
	 * Default constructor, persistence use.
	 */
	public QuestionOption() {
		this.text = "";
		this.preselected = Boolean.FALSE;
	}

	/**
	 * @return the version
	 */
	public Long getVersion() {
		return this.version;
	}

	/**
	 * @param aVersion the version to set
	 */
	public void setVersion(Long aVersion) {
		this.version = aVersion;
	}

	/**
	 * @return ID
	 */
	public Integer getQuestionOptionId() {
		return this.questionOptionId;
	}

	/**
	 * @param aQuestionOptionId ID
	 */
	public void setQuestionOptionId(Integer aQuestionOptionId) {
		this.questionOptionId = aQuestionOptionId;
	}

	/**
	 * @return text of the option
	 */
	public String getText() {
		return this.text;
	}

	/**
	 * @param aText text of the option
	 */
	public void setText(String aText) {
		this.text = aText;
	}

	/**
	 * @return the question
	 */
	public ChoiceQuestion getQuestion() {
		return this.question;
	}

	/**
	 * @param aQuestion the question to set
	 */
	public void setQuestion(ChoiceQuestion aQuestion) {
		this.question = aQuestion;
	}

	/**
	 * @return the preselected
	 */
	public Boolean getPreselected() {
		return this.preselected;
	}

	/**
	 * @param isPreselected if is preselected
	 */
	public void setPreselected(Boolean isPreselected) {
		this.preselected = isPreselected;
	}

	/**
	 * Excluded attributes are: version and question.
	 */
	@Override
	protected String[] getExcludedAttributes() {
		return new String[] { "version", "question" };
	}
}
